#include "CUnit.h"

#include "Classes/TextureManager.h"
#include "Animation.h"
#include "SpriteMaker.h"

#include <windows.h>

enum
EUnitState
{
	eNon,
	eMove,
	eAttack,
	eDie
};

const int nWarrior_Move = 11;

CUnit::CUnit(void)
{
}

CUnit::~CUnit(void)
{
}

void CUnit::Act(void)
{
	Move();
}

CWarrior::CWarrior(int _nMovingWay)
{
	m_nMovingWay = _nMovingWay;
	m_nX = 200;
	m_nY = -100;
	m_nState = eMove;
	m_nMoveDelay = 1;
	m_nFinalTime_Move = GetTickCount() + (m_nMoveDelay * 1000);
	SharedSpriteMaker.createAnimation("Warrior_Move", nWarrior_Move);
	SharedSpriteMaker.getAnimation(nWarrior_Move)->setGrid(4,1);
	SharedSpriteMaker.getAnimation(nWarrior_Move)->setSize(80,80);
	SharedSpriteMaker.getAnimation(nWarrior_Move)->setSpeed(1.0f);
}

CWarrior::~CWarrior(void)
{
}

void CWarrior::Move(void)
{
	int nNowTime = GetTickCount();
	if(m_nMoveDelay <= nNowTime - m_nFinalTime_Move)
	{
		m_nX +=5;
		SharedSpriteMaker.getAnimation(nWarrior_Move)->run(1.0f);
		m_nFinalTime_Move = GetTickCount() + (m_nMoveDelay * 1000);
	}
	SharedSpriteMaker.getAnimation(nWarrior_Move)->setPosition(m_nX,m_nY,2);
}